#include <stdio.h>

#define ALLOCSIZE 10000

static char allocbuf[ALLOCSIZE];
static char *allocp = allocbuf;

char *alloc(int n)
{
    if(allocbuf + ALLOCSIZE - allocp >= n)
    {
        allocp += n;
        return allocp - n; 
    }
    else
    {
        return 0;
    }    
}

void afree(char *p)
{
    if(p >= allocbuf && p < allocbuf + ALLOCSIZE)
        allocp = p;
}

int main(void)
{
    printf("%p\n", allocp);
    char *p1 = alloc(16);
    printf("%p, %p\n", p1, allocp);
    char *p2 = alloc(16);
    printf("%p, %p\n", p2, allocp);
    afree(p1);
    printf("%p, %p\n", p1, allocp);
    afree(p2);
    printf("%p, %p\n", p2, allocp);

    return 0;
}